#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    //
    int t,n,k;
    long long s = 0,cnt = 0;
    int m;
    vector<int>v;
    v.resize(51);
    //
    scanf("%d",&t);
    while (t--) 
    {
        scanf("%d %d",&n,&k);
        m = n;
        while (m--) 
        {
            int temp;
            scanf("%d",&temp);
            v.push_back(temp);
        }
        for (vector<int>::iterator it = v.begin();
        it != v.end();it++)
        {
            if (*it >= k)   s+=*it;
            else if (*it == 0&&s>=1) 
            {
                s--;
                cnt++;
            } 
        }
        printf("%d\n",cnt);
    }

    return 0;
}